package uniLearn.data;

import java.util.ArrayList;

public class AssignmentGroup {
	//define
	//public static final int ID_MAX_LENGTH = 10;
	public static final int NAME_MAX_LENGTH = 50;
		
	//variable
	private int id;
	private String name;
	private int acId;
	private String leader;
	private ArrayList<String> member;
	
	//constructor
	public AssignmentGroup(int id, String name, int acId) {
		this.setName(name);
		
		this.id = id;
		this.acId = acId;
	}

	//get method
	public int getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public int getACId() {
		return acId;
	}

	public String getLeader() {
		return leader;
	}

	public ArrayList<String> getMember() {
		return member;
	}

	//set method
	public void setName(String name) {
		if(name.isEmpty() || name.length() > NAME_MAX_LENGTH) {
			//error
			return;
		}
		this.name = name;
	}

	public void setLeader(String leader) {
		if(leader.isEmpty() || leader.length() > Users.NAME_MAX_LENGTH) {
			//error
			return;
		}
		this.leader = leader;
	}
	
	public void setMember(ArrayList<String> member) {
		this.member = member;
	}

	//override
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + acId;
		result = prime * result + id;
		result = prime * result + ((leader == null) ? 0 : leader.hashCode());
		result = prime * result + ((member == null) ? 0 : member.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AssignmentGroup other = (AssignmentGroup) obj;
		if (acId != other.acId)
			return false;
		if (id != other.id)
			return false;
		if (leader == null) {
			if (other.leader != null)
				return false;
		} else if (!leader.equals(other.leader))
			return false;
		if (member == null) {
			if (other.member != null)
				return false;
		} else if (!member.equals(other.member))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
	
	@Override
	public String toString() {
		return "AssignmentGroup [id=" + id + ", name=" + name + ", acId="
				+ acId + ", leader=" + leader + "]";
	}

}
